package br.com.dev.tcc.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import br.com.dev.tcc.R;
import br.com.dev.tcc.bean.sinistro.Sinistro;

public class ListaSinistroAdapter extends BaseAdapter {

	private LayoutInflater inflater;
	private List<Sinistro> itens;

	public ListaSinistroAdapter(Context ctx, List<Sinistro> itens) {

		this.itens = itens;
		inflater = LayoutInflater.from(ctx);
	}

	@Override
	public int getCount() {

		return itens.size();
	}

	@Override
	public Object getItem(int pos) {

		return itens.get(pos);
	}

	@Override
	public long getItemId(int pos) {

		return pos;
	}

	@Override
	public View getView(int pos, View view, ViewGroup parent) {

		final Sinistro sinistro = itens.get(pos);

		view = inflater.inflate(R.layout.sinistro_lista_item, null);

		((TextView) view.findViewById(R.id.tvApolice)).setText(sinistro
				.getApolice().getHash());

		((TextView) view.findViewById(R.id.tvTipo)).setText(sinistro
				.getTipoDescricao());

		((TextView) view.findViewById(R.id.tvDescritivo)).setText(sinistro
				.getDescritivo());

		((TextView) view.findViewById(R.id.tvData)).setText(sinistro.getData());

		((TextView) view.findViewById(R.id.tvValueStatus)).setText(sinistro
				.getStatus());

		((TextView) view.findViewById(R.id.tvValueMensagem)).setText(sinistro
				.getStatusMensagem());

		return view;
	}
}
